package cn.shiwei.order.domain;

import cn.shiwei.basic.domain.BaseDomain;
import lombok.Data;
import net.bytebuddy.description.field.FieldDescription;
import org.apache.commons.lang3.time.DateUtils;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Data
public class OrderPet extends BaseDomain {
    /**
     * 银联支付
     */
    public static final Integer PAY_TYPE_BANK = 1;
    /**
     * 微信支付
     */
    public static final Integer PAY_TYPE_WECHAT = 2;
    /**
     * 支付宝支付
     */
    public static final Integer PAPAY_TYPE_ALI = 3  ;
    /**
     * 订单待支付
     */
    public static final Integer STATUS_PENDING_PAYMENT = 0;
    /**
     * 订单已支付, 待发货
     */
    public static final Integer STATUS_PAID_DELIVERY = 1;
    /**
     * 订单用户取消订单
     */
    public static final Integer STATUS_USER_CANCELED = 2;
    /**
     * 订单超时, 已取消
     */
    public static final Integer STATUS_AUTO_CANCEL = 3;
    /**
     * 订单支付失败
     */
    public static final Integer STATUS_PAYMENT_FAILED = 4;
    /**
     * 订单已发货, 待收货
     */
    public static final Integer STATUS_UNRECEIVED = 5;
    /**
     * 订单确认收货, 订单结束
     */
    public static final Integer STATUS_COMPLETE = 6;

    /**
     * 宠物id, 可以设置为数组
     */
    private Long pet_id;

    private List<Long> pet_ids;
    /**
     * 用户地址id
     */
    private Long user_add_id;
    /**
     * 支付类型
     */
    private Long pay_type;
    /**
     * 订单创建时间
     */
    private Date create_time = new Date();
    /**
     * 订单状态
     */
    private Integer state;
    /**
     * 订单商品总金额
     */
    private BigDecimal price;
    /**
     * 订单编号
     * 设置一个初始的订单编号, 为uuid随机数去掉-
     */
    private String sn = UUID.randomUUID().toString().replaceAll("_", "");
    /**
     * 订单过期时间
     */
    private Date expire_time = DateUtils.addMinutes(create_time, 30);
    /**
     * 订单商品数
     */
    private Integer total = 1;
    /**
     * 用户id
     */
    private Long UserId;


    public OrderPet() {
    }

    public OrderPet(Long pet_id, Long user_add_id, Long pay_type, Integer state, BigDecimal price, Long userId) {
        this.pet_id = pet_id;
        this.user_add_id = user_add_id;
        this.pay_type = pay_type;
        this.state = state;
        this.price = price;
        UserId = userId;
    }

    public OrderPet(List<Long> pet_ids, Long user_add_id, Long pay_type, Integer state, BigDecimal price, Long userId) {
        this.pet_ids = pet_ids;
        this.user_add_id = user_add_id;
        this.pay_type = pay_type;
        this.state = state;
        this.price = price;
        UserId = userId;
    }
}
